home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg4.cab / charmap.py < prev    next >
Text File  |  2005-11-19  |  1KB  |  51 lines

  1. """ Generic Python Character Mapping Codec.
  2.  
  3.     Use this codec directly rather than through the automatic
  4.     conversion mechanisms supplied by unicode() and .encode().
  5.  
  6.  
  7. Written by Marc-Andre Lemburg (mal@lemburg.com).
  8.  
  9. (c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
  10.  
  11. """#"
  12.  
  13. import codecs
  14.  
  15. ### Codec APIs
  16.  
  17. class Codec(codecs.Codec):
  18.  
  19.     # Note: Binding these as C functions will result in the class not
  20.     # converting them to methods. This is intended.
  21.     encode = codecs.charmap_encode
  22.     decode = codecs.charmap_decode
  23.  
  24. class StreamWriter(Codec,codecs.StreamWriter):
  25.  
  26.     def __init__(self,stream,errors='strict',mapping=None):
  27.  
  28.         codecs.StreamWriter.__init__(self,stream,errors)
  29.         self.mapping = mapping
  30.  
  31.     def encode(self,input,errors='strict'):
  32.  
  33.         return Codec.encode(input,errors,self.mapping)
  34.  
  35. class StreamReader(Codec,codecs.StreamReader):
  36.  
  37.     def __init__(self,stream,errors='strict',mapping=None):
  38.  
  39.         codecs.StreamReader.__init__(self,strict,errors)
  40.         self.mapping = mapping
  41.  
  42.     def decode(self,input,errors='strict'):
  43.  
  44.         return Codec.decode(input,errors,self.mapping)
  45.  
  46. ### encodings module API
  47.  
  48. def getregentry():
  49.  
  50.     return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
  51.